//
//  picPickerCollectionView.swift
//  WBTest
//
//  Created by 张海峰 on 2017/8/1.
//  Copyright © 2017年 张海峰. All rights reserved.
//

import UIKit
private let  picPickerCell = "picPickerCell"
private let  edgeMargin : CGFloat = 10
class picPickerCollectionView: UICollectionView {
    
    override func awakeFromNib() {
        super.awakeFromNib()
        //设置collectionView的layout
        let layout = collectionViewLayout as! UICollectionViewFlowLayout
        let itemWH = (UIScreen.main.bounds.width - 4 * edgeMargin) / 3
         layout.itemSize = CGSize(width: itemWH, height: itemWH)
        layout.minimumInteritemSpacing = edgeMargin
        layout.minimumLineSpacing = edgeMargin
        register(UINib.init(nibName: "PicPickerCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: picPickerCell)
        dataSource = self
        //设置内边距
        contentInset = UIEdgeInsets(top: edgeMargin, left: edgeMargin, bottom: 0, right: edgeMargin)
    }
}
extension picPickerCollectionView : UICollectionViewDataSource
{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 1
    }
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        //创建cell
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: picPickerCell, for: indexPath)
        //给cell设置数据
       // cell.backgroundColor = UIColor.red
        return cell
        
    }
}
